package com.wontube.client.io;

import java.util.HashMap;

/**
 * @author yuechao
 *
 */
public final class ProtocolProxyFactory {
	private static final HashMap<String, IObjectProtocolProxy> proxyMap = new HashMap<String, IObjectProtocolProxy>();
	
	private ProtocolProxyFactory() {	
	}

	static {
		// 内置 data format 支持 java
		IObjectProtocolProxy proxy = new JavaObjectProtocolProxy();
		proxyMap.put(proxy.getDataFormat(), proxy);
	}
	
	public static final void regist(IObjectProtocolProxy proxy) {
		proxyMap.put(proxy.getDataFormat(), proxy);
	}
	
	public static final IObjectProtocol createProtocol(String dataFormat) {
		IObjectProtocolProxy proxy = proxyMap.get(dataFormat);
		if (proxy == null) {
			return null;
		}
		
		return proxy.createProtocol();
	}
}
